/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package session.stateless;

import entity.InvoiceDetails;
import java.sql.Timestamp;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import java.io.File;
import javax.persistence.PersistenceContext;

/**
 *
 * @author yont
 */
@Stateless
public class InvoiceDetailsSession implements InvoiceDetailsSessionLocal {
    
    @PersistenceContext
    private EntityManager em;
    
    @Override
    public InvoiceDetails getInvoiceDetails(String merchantUserName) {
        Query query = em.createQuery("SELECT i FROM InvoiceDetails i WHERE i.merchantUserName = :merchantUserName");
        query.setParameter("merchantUserName" , merchantUserName);
        

    }

    @Override
    public Long addInvoiceDetails(Timestamp invoiceDate, String merchantBillingAddress, String merchantManagerName, String merchantContactNumber) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public int modifyInvoiceDetails() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public static void pdfOpen(String[] args) {
        String fileName;  //dir of pdf file
        fileName = "www.comp.nus.edu.sg/~tonyfang/A1.pdf"; //"servername" + args[0] + ".pdf"
        
 	  try {
 		if ((new File(fileName)).exists()) {
			Process p = Runtime
			   .getRuntime()
			   .exec("rundll32 url.dll,FileProtocolHandler " + fileName);
			p.waitFor();
 		} else {
    			System.out.println("File is not exists");
		}
		System.out.println("Done"); 
  	  } catch (Exception ex) {
		ex.printStackTrace();
	  } 
	}
    
}
